package com.xinbochuang.machine.admin.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xinbochuang.machine.admin.dto.ContrastEquDto;
import com.xinbochuang.machine.admin.service.macRoom.IContrastEquipmentDetailService;
import com.xinbochuang.machine.common.controller.BaseController;
import com.xinbochuang.machine.framework.web.domain.AjaxResult;

/**
 * @author 杜文博
 * @date 2020-09-21
 */
@RestController
@RequestMapping("/contrast-equipment-detail")
public class ContrastEquipmentDetailController extends BaseController {

    @Autowired
    IContrastEquipmentDetailService contrastEquipmentDetailService;

    @GetMapping("/list")
    public AjaxResult list(ContrastEquDto contrastEqudTO) {
        List<ContrastEquDto> result = contrastEquipmentDetailService.selectContrasEquList(contrastEqudTO);
        Integer totalCount = contrastEquipmentDetailService.selectContrasEquCount(contrastEqudTO);
        return AjaxResult.data(result, totalCount);
    }

    @GetMapping("/updatEqu")
    public AjaxResult updatEquDetail(@RequestParam("checkKey") Integer checkKey,
                                     @RequestParam("equIds") String equIds,
                                     @RequestParam("planId") String planId
    ) {
        Integer endResult = contrastEquipmentDetailService.updatEquDetail(checkKey, equIds,planId);
        if (endResult == 1) {
            return toAjax(true);
        } else {
            return toAjax(false);
        }
    }
}

